if lib and not lib.GetMaxLabelID then


function lib:GetMaxLabelID(tag)
	if not self.max_label_ids then self.max_label_ids = {} end
	local id = self.max_label_ids[tag]
	if not id then
		local c = self:GetLastCandle(tag)
		if c then
			id = self:AddLabel(tag,
				{DATE = self:FormatDate(c.datetime),
				TIME = self:FormatDate(c.datetime),
				YVALUE=c.close,
				TEXT="test"})
			if id then
				DelLabel(tag, id)
			end
		end
	end
	return id or 100
end


function lib:SetMaxLabelID(tag, id)
	if not self.max_label_ids then self.max_label_ids = {} end
	if id then
		id = int(id)
		if not self.max_label_ids[tag] or id > self.max_label_ids[tag] then
			self.max_label_ids[tag] = id
		end
	end
end


function lib:AddLabel(tag, label_params)
	local id = AddLabel(tag, label_params)
	if id then
		id = int(id)
		lib:SetMaxLabelID(tag, id)
		return id
	end
end


end -- of file
